//
//  PhotoDetailController.swift
//  DMCamera
//
//  Created by 李浩 on 2017/8/3.
//  Copyright © 2017年 李浩. All rights reserved.
//

import UIKit
import Photos

class PhotoDetailController: UIViewController {
    
    var collection: PHAssetCollection!
    var images: [UIImage] = []
    var assets: [PHAsset] = []

    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        view.addSubview(coll)
        let asset = PHAsset.fetchAssets(in: collection, options: nil)
        asset.enumerateObjects({ (asset, num, pointer) in
            self.assets.append(asset)
//            PHImageManager.default().requestImage(for: asset, targetSize: UIScreen.main.bounds.size, contentMode: .aspectFit, options: nil, resultHandler: { (image, dic) in
//                if (image != nil) {
//                    self.images.append(image!)
//                }
//            })
        })
        coll.dataArr = assets
        coll.reloadData()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    lazy var coll: PhotoCollectionView = {
       let collection = PhotoCollectionView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height))
        return collection
    }()
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
